package com.exm.collectcodenew.kafka.producer.customSerializer2;

import java.io.*;

public class BeanUtils {
    public static byte[] beanToByte(Object obj) throws IOException {
        byte [] bb =null;
        ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
        ObjectOutputStream outputStream = new ObjectOutputStream(byteArray);
        outputStream.writeObject(obj);
        outputStream.flush();
        bb=byteArray.toByteArray();
        return bb;
    }
    public static Object byteToObj(byte[] bytes) throws IOException, ClassNotFoundException {
        Object readObject =null;
        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
        ObjectInputStream inputStream = new ObjectInputStream(in);
        readObject=inputStream.readObject();
        return readObject;
    }
}
